{extend name="Administrator/nav"}
{block name="title"}学院管理{/block}
{block name="content"}
<div class="row">
    <div class="col-md-12">
        <div class="container">
            <div class="row">
                <div class="col-md-8">
                    <form class="form-inline" action="{:url()}">
                        <div class="form-group">
                            <label class="sr-only" for="name">学院管理</label>
                            <input name="name" type="text" class="form-control" placeholder="请输入要搜索的关键字..." value="{:input('get.name')}">
                        </div>
                        <button type="submit" class="btn btn-default"><i class="glyphicon glyphicon-search"></i>&nbsp;查询</button>
                    </form>
                </div>
                <div class="col-md-4 text-right">
                    <button class="btn btn-primary" data-toggle="modal" data-target="#mymodal-data"><i class="glyphicon glyphicon-plus"></i>&nbsp;增加</button>
                    <div class="modal" id="mymodal-data" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
                        <div class="modal-dialog">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                    <h4 class="modal-title text-left">增加学院</h4>
                                </div>
                                <div class="modal-body text-left">
                                    <form action="{:url('save')}" method="post">
                                        <label>学院名称：</label>
                                        <input type="text" name="name">
                                        <button type="submit" class="btn btn-primary">保存</button> 
                                    </form>  
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <hr />
            <table  class="table table-hover table-bordered">
                <tr class="info" >
                    <th width="10%">ID</th>
                    <th width="70%">学院名</th>
                    <th width="20%">操作</th>
                </tr>
                {volist name="colleges" id="college" key="key"}
                <tr>
                    <td>{$key}</td>
                    <td>{$college->getData('name')}</td>
                    <td>
                        <button class="btn btn-sm btn-primary" data-toggle="modal" data-target="#editCollege{$key}"><i class="glyphicon glyphicon-pencil"></i>&nbsp;编辑</button>

                    <a class="btn btn-sm btn-danger" href="{:url('delete?id=' . $college->getData('id'))}"><i class="glyphicon glyphicon-trash"></i>&nbsp;删除</a>

                        <div class="modal" id="editCollege{$key}" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"></span></button>
                                    <h4 class="modal-title">编辑学院</h4>
                                </div>

                                <div class="modal-body">
                                    <form action="{:url('update')}" method="post">
                                        <label>学院名称：</label>
                                        <input type="hidden" name="id" value="{$college->getData('id')}" />
                                        <input type="text" name="name" id="name" value="{$college->getData('name')}">
                                        <button type="submit" class="btn btn-primary">保存</button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                    </td>
                </tr>  
             {/volist}
            </table>
            {:$colleges->render()}
        </div>
     </div>
</div>
{/block}